import { createRouter, createWebHistory } from "vue-router";

// 创建路由实例并配置 history 模式
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    // 添加根路径的路由配置，这里以重定向到 /login 为例
    {
      path: "/",
      redirect: "/login", // 可以根据需求修改重定向目标
    },
    {
      path: "/login",
      name: "login",
      component: () => import("../components/login.vue"),
    },
    {
      path: "/index",
      name: "index",
      component: () => import("../components/index.vue"),
      children: [
        {
          path: "shouye", // 移除前缀 /index
          name: "shouye",
          component: () => import("../components/shouye.vue"),
        },
        {
          path: "department",
          name: "department",
          component: () => import("../components/Department.vue"), // 修正拼写错误
        },
        {
          path: "people",
          name: "people",
          component: () => import("../components/people.vue"),
        },
        {
          path: "gonggao",
          name: "gonggao",
          component: () => import("../components/gonggao.vue"),
        },
      ],
    },
  ],
});

export default router;
